﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using haber.classes;

namespace haber
{
    public partial class FBcallBack : System.Web.UI.Page
    {
        public string tokens;
        public string id;
        protected void Page_Load(object sender, EventArgs e)
        {
       //     string url = "";
            oAuth oAuth = new oAuth();

            if (Request["code"] == null)
            {
                //Redirect the user back to Facebook for authorization.
                Response.Redirect(oAuth.AuthorizationLinkGet("-1"));
            }
            else
            {
                try
                {
                    //Get the access token and secret.
                    if (Request["id"] != null)
                    {
                        id = Request["id"].ToString();
                    }
                    oAuth.AccessTokenGet(Request["code"],id);
                  

                    if (oAuth.Token.Length > 0)
                    {
                        tokens = oAuth.Token;
                        //We now have the credentials, so we can start making API calls
                        //url = "https://graph.facebook.com/me/feed?access_token=" + oAuth.Token;
                        //string json = oAuth.WebRequest(oAuthFacebook.Method.POST, url, HttpUtility.UrlEncode("TestingAPI"));

                    }
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
            }
        }
    }
}